package org.tao.lightningmq.nameserver.replication;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author lht
 * @date 2025/1/17 - 15:04
 * @description:
 */
public abstract class BaseReplicationTask {

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseReplicationTask.class);

    private final String taskName;

    public BaseReplicationTask(String taskName) {
        this.taskName = taskName;
    }

    public void startTaskAsync() {
        Thread task = new Thread(() -> {
            LOGGER.info("start job:{}", taskName);
            startTask();
        });
        task.setName(taskName);
        task.start();
    }

    protected abstract void startTask();

}
